//
//  SearchHistoryArray.m
//  RouteSearcher
//
//  Created by wenqingzhou on 3/9/11.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "SearchHistoryModel.h"

#define MAX_HISTORY_SEARCH 5

@implementation SearchHistoryModel
@synthesize searchHistoryArray;
+(SearchHistoryModel *)getSingleton
{
	if (searchHistory == nil) {
		searchHistory = [[super allocWithZone:NULL] init];
		searchHistory.searchHistoryArray=[[NSMutableArray alloc] init];
	}
	return searchHistory;
}
+ (id)copyWithZone:(NSZone *)zone
{
	return [[self getSingleton] retain];
}
+ (id)allocWithZone:(NSZone *)zone
{
	return [[self getSingleton] retain];
}
- (void)restore:(RouteRequestResultModel *)rrrm
{
	if([searchHistoryArray count]>=MAX_HISTORY_SEARCH)
	{
		[searchHistoryArray removeLastObject];
		[searchHistoryArray insertObject:rrrm atIndex:0];
	}
	else {
		[searchHistoryArray insertObject:rrrm atIndex:0];
	}

}
- (id)retain
{
	return self;
}
- (void)release
{
	
}
- (id)autorelease
{
	return self;
}
- (NSUInteger)retainCount
{
	return NSUIntegerMax;
}
- (void)dealloc
{
	[self.searchHistoryArray release];
	[super dealloc];
}
@end
